(function() {
    'use strict';

    function enumList() {
        // add local enum data which doesn't provide by api
        this.enumJsonData = {

            /*
             产权的性质
             */
            'houseType': {
                "公房": "公房",
                "商品房": "商品房",
                "商住两用": "商住两用",
                "其他": "其他"
            },
            /*
             房屋的朝向
             */
            'houseOrientations': {
                '南': '南',
                '东南': '东南',
                '西南': '西南',
                '南北': '南北',
                '其他':'其他'
            },
            /*
             审核状态
             */
            'verifyStatus': {
                "0": "未审核",
                "1": "已通过",
                "2": "不通过"
            },
            // 仅供审核状态时间轴显示
            'verifyStatusDisplay': {
                "UNVERIFY": "未发起",
                "ONLINEVERIFY": "发起审核",
                "OFFLINEVERIFY": "线上审核通过",
                "ONLINEREJECT": "线上审核未通过",
                "OFFLINEREJECT": "线下审核未通过",
                "PASSVERIFY": "已通过审核"
            },
            /*
             房源签约状态
             */
            'signStatus': {
                "UNSIGN": "未签约",
                "SIGN": "已签约",
                "BREACH": "已违约"
            },
            /*
             房源跟进状态
             */
            'followStatus': {
                "FOLLOWING": "跟进中",
                "ABANDONED": "已废弃"
            },
            /*
             房源异常状态
             */
            'exceptionStatus': {
                "NORMAL": "正常",
                "ABNORMAL": "异常"
            },
            livingCondition:{
                '空置':"空置",
                '自住':"自住",
                '租赁':'租赁'
            },
            decorationCondition:{
                '毛坯':'毛坯',
                '简装修':"简装修",
                '中等装修':'中等装修',
                '精装修':"精装修"
            },
            houseStatus:{
                '待审核':'待审核',
                '待签约':"待签约",
                '待售出':"待售出",
                '已售出':"已售出",
                '其他':"其他"
            },
            isAuth:{
                "0":"未认证",
                "1":"待审核",
                "2":"未通过",
                "3":"已认证"
            },
            rewardStatus:{
                "1":"悬赏中",
                "2":"已完成",
                "3":"已取消"
            },
            lockType:{
                "0":"钥匙锁",
                "1":"wifi智能锁"
            },
            powerLeftValue:{
                "0":"正常",
                "1":"低电量"
            },
            wifiOnlineStatus:{
                "on":"在线",
                "off":"离线"
            },
            lockFixStatus:{
                0:"未安装",
                1:"已安装",
                2:"安装中"
            },
            lockInquireType:{
                week:"本周",
                month:"本月"
            },
            pointType:{
                ACTIONPOINT:"体力",
                VISITPOINT:"看房积分"
            },
            exchangeStatus:{
                0:"待处理",
                1:"已打款"
            },
            bannerType:{
                1:'微信端',
                2:'PC端'
            },
            dataStatus:{
                'AVAILABLE':"启用",
                'FORBID':"禁用",
                'DELETE':"已删除"
            }
        };
    }

    enumList.prototype = {
        /**
         * 初始化枚举值
         * @return {[type]} [description]
         */
        init: function() {
            var self = this;
            // var enumJsonData = {};
            $.post(window.globalHost + '/agent-sys/admin/getEnumList.do').success(function(data) {
                if ("1" == data.code) {
                    layer.alert(data.res.msg);
                } else if ("0" == data.code) {
                    self.enumJsonData = _.assign(self.enumJsonData, data.res.data);
                }
                // self.enumJsonData = enumJsonData;
            })
        },
        /**
         * 根据枚举key获取枚举对象
         * @return {[type]} [description]
         */
        getEnumJsonByEnumKey: function(key) {
            return !!this.enumJsonData[key] ? this.enumJsonData[key] : {};
        },
        /**
         * 获取枚举value，默认返回第一项
         */
        getEnumValue:function(enumName,enumKey){
            var enumObj=this.enumJsonData[enumName];
            if(enumObj===undefined){
                throw new Error("找不到该枚举类型:",enumName);
            }
            return enumKey ? enumObj[enumKey] : _.first(_.values(enumObj));
        }
    };

    window.enumObject = new enumList();
}).call(this);
